var player = new Vue({
    el:"#player",
    data:{
        //搜索框信息
        query:"",
        //搜索结果 歌曲的信息
        musicList:[],
        //歌曲地址
        musicUrl:"",
        //歌曲的封面
        musicCover: "",
        // 歌曲评论
        hotComments: [],
        // 歌曲播放状态 fasle表示暂停
        isPlaying:false,
        // 遮罩层的显示状态
        isShow: false,
        //mv地址
        mvUrl: ""

    },
    methods:{
        //搜索歌曲信息
        searchMusic:function () {
            var that = this;
            axios.get("https://autumnfish.cn/search?keywords="+that.query).then(function (response) {
                that.musicList = response.data.result.songs;
                // console.log(response.data.result.songs);
            },function (err) {});
        },

        //歌曲播放
        playMusic:function (musicId) {
            var that = this;
            //播放歌曲
            axios.get("https://autumnfish.cn/song/url?id=" + musicId).then(function (response) {
                that.musicUrl = response.data.data[0].url;
            },function (err) {});

            //获取歌曲的详细信息————封面
            axios.get("https://autumnfish.cn/song/detail?ids=" + musicId).then(function (response) {
                that.musicCover = response.data.songs[0].al.picUrl;
            },function (err) {});

            //获取评论信息
            axios.get("https://autumnfish.cn/comment/hot?type=0&id=" + musicId).then(function (response) {
                that.hotComments = response.data.hotComments;
            },function (err) {})
        },

        // 歌曲播放
        play: function() {
            // console.log("play");
            this.isPlaying = true;
        },
        // 歌曲暂停
        pause: function() {
            // console.log("pause");
            this.isPlaying = false;
        },

        //mv播放
        playMV:function (mvid) {
            var that = this;
            axios.get("https://autumnfish.cn/mv/url?id=" + mvid).then(function (response) {
                that.isShow = true;
                that.mvUrl = response.data.data.url;
            },function (err) {})
        },

        // 隐藏
        hide: function() {
            this.isShow = false;
        }

    }
})